<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<RMH.Entities.Stay>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	All Current Stays
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>All Current Stays</h2>

    <table>
        <tr>
            <th></th>
            <th>
                Room #
            </th>
            <th>
                Patient Name
            </th>
            <th>
                Checkin Date
            </th>
            <th>
                Checkout Date
            </th>
        </tr>

    <% foreach (var item in Model.OrderBy(r => r.Room.RoomNumber)) { %>
    
        <tr>
            <td>
                <%= Html.ActionLink("Edit", "Edit", new { id=item.Id }) %> |
                <%= Html.ActionLink("Details", "Details", new { id=item.Id })%>
            </td>
            <td>
                <%= item.Room == null ? string.Empty : Html.Encode(item.Room.RoomNumber) %>
            </td>
            <td>
                <%= item.Patient == null ? string.Empty : Html.Encode(item.Patient.GetFullNameSortable()) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:g}", item.CheckinDate)) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:g}", item.CheckoutDate)) %>
            </td>
        </tr>
    
    <% } %>

    </table>

    <p>
        <%= Html.ActionLink("Create New", "Edit") %>
    </p>

</asp:Content>

